<template>
  <div>
    <el-form
      style="margin-top: 20px"
      :model="form"
      ref="ruleForm"
      label-width="200px"
    >
      <el-form-item label="将配置恢复出厂默认设置"></el-form-item>
      <el-form-item label="保持IP不变" prop="iKeepIP">
        <el-switch
          v-model="form.iKeepIP"
          :active-value="activeValue"
          :inactive-value="inactiveValue"
        ></el-switch>
      </el-form-item>
      <el-form-item label="是否需要从平台拉取图片库" prop="iReregisterFromAiot" v-if="false">
        <el-switch
          v-model="form.iReregisterFromAiot"
          :active-value="activeValue"
          :inactive-value="inactiveValue"
        ></el-switch>
      </el-form-item>
      <el-form-item>
        <!-- <el-popover placement="top" width="160" v-model="visible">
          <p>
            <i class="el-icon-error" style="color: #f00"></i>
            恢复出厂设置后，数据将无法恢复，你确定恢复出厂设置吗？
          </p>
          <div style="text-align: right; margin: 0">
            <el-button
              type="primary"
              size="mini"
              @click="submitForm('ruleForm')"
              >确定</el-button
            >
            <el-button size="mini" @click="visible = false">取消</el-button>
          </div>
          <el-button slot="reference" type="primary">恢复出厂设置</el-button>
        </el-popover> -->
        <el-button type="primary" @click="submitForm('ruleForm')">
          恢复出厂设置
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { resetDeviceApi } from "@/api/access/equipment";
export default {
  name: "MvCloudgateTerminalResetDevice",

  data() {
    return {
      // visible: false,
      activeValue: 1,
      inactiveValue: 0,
      form: {
        iKeepIP: 1,
        iReregisterFromAiot: 0,
      },
    };
  },

  mounted() {
  },

  methods: {
    submitForm() {
      // this.visible = false;
      this.$confirm(
        "恢复出厂设置后，数据将无法恢复，你确定恢复出厂设置吗？",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          resetDeviceApi(this.form).then((res) => {
            console.log(res);
            this.$message.success("恢复出厂设置成功,请重新登录！");
            this.$store.dispatch("LogOut").then(() => {
              location.href = "/index";
            });
          });
        })
        .catch(() => {
          // this.$message.info("已取消删除");
        });
    },
  },
};
</script>

<style lang="scss" scoped></style>
